//remind.js
//获取应用实例
const app = getApp()
Page({
  data: {
    remind: app.globalData.remind,
  },
  onShow: function () {
    var that = this;
    wx.request({
      url: 'https://hi.slickghost.com/WebTest/Operate',
      data: {
        choice: 'findemailtip',
        openid: app.globalData.openid,
      },
      header: {
        'content-type': 'json'
      },
      success: (res) => {
        app.globalData.remind = res.data
        that.setData({
          remind: app.globalData.remind
        })
       
      }
    })
    wx.request({
      url: 'https://hi.slickghost.com/WebTest/Operate',
      data: {
        choice: 'findemailmessage',
        openid: app.globalData.openid,
      },
      header: {
        'content-type': 'json'
      },
      success: (res) => {
        app.globalData.email = res.data
      }
    })
  },
  radioChange: function (e) {
    app.globalData.remind = e.detail.value;
    if (app.globalData.email != '您暂未绑定邮箱' && app.globalData.remind != '') {
      wx.request({
        url: 'https://hi.slickghost.com/WebTest/Operate',
        data: {
          choice: 'insertemailtip',
          openid: app.globalData.openid,
          emailtip: app.globalData.remind
        },
        header: {
          'content-type': 'json'
        },
        success: function () {
          wx.showToast({
            title: "设置成功",
            icon: 'success',
            duration: 1000
          })
        }
      })
    }
    else {
      wx.showModal({
        title: '提示',
        content: '您还未绑定邮箱',
      })
      this.onShow();
    }
  }
})


